-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swap ca cb channels #93
Conversation
src/aposteriori/data_prep/cli.py
Outdated
type=click.Choice(["CNO", "CNOCB", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP"]), | ||
type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For backwards compatibility, can we add both?
type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP" ]),
src/aposteriori/data_prep/cli.py
Outdated
elif atom_encoder == "CNOCACB": | ||
codec = Codec.CNOCACB() | ||
elif atom_encoder == "CNOCACBQ": | ||
codec = Codec.CNOCACBQ() | ||
elif atom_encoder == "CNOCACBP": | ||
codec = Codec.CNOCACBP() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here maybe let's add both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few things to change for backward compatibility.
src/aposteriori/data_prep/cli.py
Outdated
"CNOCBCA", | ||
"CNOCBCAQ", | ||
"CNOCBCAP", | ||
], f"Expected encoder to be CNO, CNOCB, CNOCBCA, CNOCBCAQ, CNOCBCAP, but got {atom_encoder}" | ||
"CNOCACB", | ||
"CNOCACBQ", | ||
"CNOCACBP", | ||
], f"Expected encoder to be CNO, CNOCB, CNOCACB, CNOCACBQ, CNOCACBP, but got {atom_encoder}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again here.
I would say let's raise a warning if you are using the old encoders saying they are deprecated and will be removed in future versions.
src/aposteriori/data_prep/cli.py
Outdated
codec = Codec.CNO() | ||
elif atom_encoder == "CNOCB": | ||
codec = Codec.CNOCB() | ||
elif atom_encoder == "CNOCBCA": | ||
codec = Codec.CNOCBCA() | ||
elif atom_encoder == "CNOCBCAQ": | ||
codec = Codec.CNOCBCAQ() | ||
elif atom_encoder == "CNOCBCAP": | ||
codec = Codec.CNOCBCAP() | ||
elif atom_encoder == "CNOCACB" or atom_encoder == "CNOCBCA": | ||
codec = Codec.CNOCACB() | ||
if atom_encoder == "CNOCBCA": | ||
warnings.warn("CNOCBCA encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACB") | ||
elif atom_encoder == "CNOCACBQ" or atom_encoder == "CNOCBCAQ": | ||
codec = Codec.CNOCACBQ() | ||
if atom_encoder == "CNOCBCAQ": | ||
warnings.warn("CNOCBCAQ encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACBQ") | ||
elif atom_encoder == "CNOCACBP" or atom_encoder == "CNOCBCAP": | ||
codec = Codec.CNOCACBP() | ||
if atom_encoder == "CNOCBCAP": | ||
warnings.warn("CNOCBCAP encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACBP") | ||
else: | ||
assert atom_encoder in [ | ||
"CNO", | ||
"CNOCB", | ||
"CNOCACB", | ||
"CNOCACBQ", | ||
"CNOCACBP", | ||
"CNOCBCA", | ||
"CNOCBCAQ", | ||
"CNOCBCAP", | ||
], f"Expected encoder to be CNO, CNOCB, CNOCBCA, CNOCBCAQ, CNOCBCAP, but got {atom_encoder}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we clean up this section to
# Mapping of current atom encoders to their corresponding Codec classes
current_codec_mapping = {
"CNO": Codec.CNO,
"CNOCB": Codec.CNOCB,
"CNOCACB": Codec.CNOCACB,
"CNOCACBQ": Codec.CNOCACBQ,
"CNOCACBP": Codec.CNOCACBP
}
# List of deprecated encodings and their replacements
deprecated_encodings = {
"CNOCBCA": "CNOCACB",
"CNOCBCAQ": "CNOCACBQ",
"CNOCBCAP": "CNOCACBP"
}
# Create Codec based on atom_encoder
if atom_encoder in current_codec_mapping:
codec = current_codec_mapping[atom_encoder]()
elif atom_encoder in deprecated_encodings:
replacement = deprecated_encodings[atom_encoder]
codec = current_codec_mapping[replacement]()
warnings.warn(f"{atom_encoder} encoding is deprecated and will be removed in future versions, "
f"atoms will be encoded as {replacement}")
else:
raise ValueError(f"Unknown atom_encoder: {atom_encoder}")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny thing
I made the changes except for the else condition because Click.choice for the -ae already handles this when an atom encoder is not valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for formatting!
Change the position of CA CB channels for readability and consistency